package com.splic.product.service.impl;

import java.util.Date;
import java.util.List;
import com.splic.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.splic.product.mapper.UserPhysiologicalCycleDataMapper;
import com.splic.product.domain.UserPhysiologicalCycleData;
import com.splic.product.service.UserPhysiologicalCycleDataService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户[女性]生理周期数据Service业务层处理
 * 
 * @author singe
 * @date 2022-01-04
 */
@Service
public class UserPhysiologicalCycleDataServiceImpl implements UserPhysiologicalCycleDataService
{
    @Autowired
    private UserPhysiologicalCycleDataMapper userPhysiologicalCycleDataMapper;

    /**
     * 查询用户[女性]生理周期数据
     * 
     * @param id 用户[女性]生理周期数据主键
     * @return 用户[女性]生理周期数据
     */
    @Override
    public UserPhysiologicalCycleData selectUserPhysiologicalCycleDataById(Long id)
    {
        return userPhysiologicalCycleDataMapper.selectUserPhysiologicalCycleDataById(id);
    }

    /**
     * 查询用户[女性]生理周期数据列表
     * 
     * @param userPhysiologicalCycleData 用户[女性]生理周期数据
     * @return 用户[女性]生理周期数据
     */
    @Override
    public List<UserPhysiologicalCycleData> selectPageList(UserPhysiologicalCycleData userPhysiologicalCycleData)
    {
        return userPhysiologicalCycleDataMapper.selectUserPhysiologicalCycleDataList(userPhysiologicalCycleData);
    }

    /**
     * 查询用户[女性]生理周期数据列表
     *
     * @param userPhysiologicalCycleData 用户[女性]生理周期数据
     * @return 用户[女性]生理周期数据
     */
    @Override
    public List<UserPhysiologicalCycleData> selectUserPhysiologicalCycleDataList(UserPhysiologicalCycleData userPhysiologicalCycleData)
    {
        return userPhysiologicalCycleDataMapper.selectUserPhysiologicalCycleDataList(userPhysiologicalCycleData);
    }

    /**
     * 新增用户[女性]生理周期数据
     * 
     * @param userPhysiologicalCycleData 用户[女性]生理周期数据
     * @return 结果
     */
    @Override
    public int insert(UserPhysiologicalCycleData userPhysiologicalCycleData)
    {
        userPhysiologicalCycleData.setCreateTime(DateUtils.getNowDate());
        return userPhysiologicalCycleDataMapper.insert(userPhysiologicalCycleData);
    }

    /**
     * 修改用户[女性]生理周期数据
     * 
     * @param userPhysiologicalCycleData 用户[女性]生理周期数据
     * @return 结果
     */
    @Override
    public int update(UserPhysiologicalCycleData userPhysiologicalCycleData)
    {
        userPhysiologicalCycleData.setUpdateTime(DateUtils.getNowDate());
        return userPhysiologicalCycleDataMapper.update(userPhysiologicalCycleData);
    }


    /**
     * 删除用户[女性]生理周期数据信息
     * 
     * @param id 用户[女性]生理周期数据主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id)
    {
        return userPhysiologicalCycleDataMapper.deleteById(id);
    }
    /**
     * 修改用户[女性]生理周期数据
     *
     * @param userPhysiologicalCycleData 用户[女性]生理周期数据信息
     * @return 结果
     */
    @Override
    @Transactional
    public int saveOrUpdate(UserPhysiologicalCycleData userPhysiologicalCycleData)
    {
        if(userPhysiologicalCycleData.getId() != null){
            userPhysiologicalCycleData.setUpdateTime(new Date());
            return userPhysiologicalCycleDataMapper.update(userPhysiologicalCycleData);
        }else{
            userPhysiologicalCycleData.setCreateTime(new Date());
            return userPhysiologicalCycleDataMapper.insert(userPhysiologicalCycleData);
        }
    }
}
